package demo4_i;

import java.util.Objects;

public class Dog extends Animal implements IRunning,ISwimming{
    //先初始化
    public Dog(String name, int age){
        super(name, age);
    }
    //抽象方法重写
    @Override
    public void eat(){
        System.out.println(this.name+"吃狗粮");
    }
    @Override
    public void run(){
        System.out.println(this.name+"冲冲冲");
    }
    @Override
    public void swim(){
        System.out.println(this.name+"游游游");
    }

    public void bark(){
        System.out.println(this.name+"汪汪汪");
    }

    public boolean equals(Object object){
        Dog tmp = (Dog)object;
        return tmp.name.equals(this.name)
                && tmp.age == this.age;
    }

    public int hashCode(){
        //return this.name.hashCode()+this.age;
          return Objects.hash(this.name, this.age);
    }

}
